package com.bingxue.edu.framework.common.util;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.lang.tree.parser.DefaultNodeParser;
import cn.hutool.core.lang.tree.parser.NodeParser;

import java.util.List;

/**
 * @author panbo
 * @since 2024/7/17
 */
public class TreeUtils {
    public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG
            .setIdKey("key")
            .setWeightKey("sort")
            .setNameKey("title");

    private TreeUtils() {
    }

    public static <E> List<Tree<E>> build(List<TreeNode<E>> list, E parentId) {
        return TreeUtil.build(list, parentId, DEFAULT_CONFIG, new DefaultNodeParser<>());
    }

//    public static <T, E> List<Tree<E>> build(List<TreeNode<E>> list, parentId) {
//        TreeUtil.build(treeNodeList, "");
//        return build(list, DEFAULT_CONFIG, nodeParser);
//    }
}
